package com.feihong.txgw.fragmentadapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.feihong.txgw.ui.activity.order.MyOrderActivity;
import com.feihong.txgw.ui.fragment.base.BaseFragment;
import com.feihong.txgw.ui.fragment.order.OrderListFragment;

import java.util.ArrayList;

/**
 * Created by Sabirjan on 2017/6/13.
 * TXGW.
 * 飞宏电子
 */

public class OrderPagerAdapter extends FragmentPagerAdapter {

    private static final String[] TITLES = {"全部", "待付款", "待收货", "待评价", "退款中"};
    private static final int[] INDEX = {MyOrderActivity.ORDER_STATE_ALL,MyOrderActivity.ORDER_STATE_PAY,
            MyOrderActivity.ORDER_STATE_TAKE,MyOrderActivity.ORDER_STATE_EVALUATE,MyOrderActivity.ORDER_STATE_REFUND};//对应的状态ID
    private ArrayList<BaseFragment> fragments;

    public OrderPagerAdapter(FragmentManager fm) {
        super(fm);
        fragments = new ArrayList<>();

        OrderListFragment fragment1 = OrderListFragment.newInstance(TITLES[0],INDEX[0]);
        OrderListFragment fragment2 = OrderListFragment.newInstance(TITLES[1],INDEX[1]);
        OrderListFragment fragment3 = OrderListFragment.newInstance(TITLES[2],INDEX[2]);
        OrderListFragment fragment4 = OrderListFragment.newInstance(TITLES[3],INDEX[3]);
        OrderListFragment fragment5 = OrderListFragment.newInstance(TITLES[4],INDEX[4]);
      //  DaiPayFragment fragment2 = DaiPayFragment.newInstance(DaiPayFragment.class.getName());
       // DaiGetFragment fragment3 = DaiGetFragment.newInstance(DaiGetFragment.class.getName());
       // DaiAssessFragment fragment4 = DaiAssessFragment.newInstance(DaiAssessFragment.class.getName());
       // BackMoneyFragment fragment5 = BackMoneyFragment.newInstance(BackMoneyFragment.class.getName());

        fragments.add(fragment1);
        fragments.add(fragment2);
        fragments.add(fragment3);
        fragments.add(fragment4);
        fragments.add(fragment5);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLES[position];
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
